package demo.icanci.proxy.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author icanci
 * @date Created in 2021/03/03 21:35
 * @version 1.0
 */
public class AlipayMethodInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        beforePay();
        Object invokeSuper = proxy.invokeSuper(obj, args);
        afterPay();
        return invokeSuper;
    }

    private void afterPay() {
        System.out.println("AlipayInvocationHandler.afterPay  取钱");
    }

    private void beforePay() {
        System.out.println("AlipayInvocationHandler.beforePay 付钱");
    }
}
